package cn.tx.util;

import cn.tx.dao.ClazzDao;
import cn.tx.dao.GradeDao;
import cn.tx.model.Clazz;
import cn.tx.model.Grade;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;


@RunWith(SpringJUnit4ClassRunner.class)// 添加spring测试方案
@ContextConfiguration("/config/spring/applicationContext.xml")// 指定spring配置文件位置
public class MyBatisTest {

    @Autowired
    private GradeDao gradeDao;

    @Test
    public void testInsert() {
        Grade c = new Grade();
        c.setName("2022");
        c.setYname("测试组");
        gradeDao.addGrade(c);
    }
    @Test
    public void testUpdate() {
        Grade c = new Grade();
        c.setId(27L);
        c.setName("2022-修改");
        c.setYname("测试组程序修改");
        gradeDao.UpdateGradeById(c);

    }
    @Test
    public void testDelete() {
        gradeDao.delete("27");
    }
    @Test
    public void testSelect() {
        List<Grade> list =  gradeDao.findAll();
        for(Grade c:list){
            System.out.println(c.getYname()+"---"+c.getName());
        }
    }

}
